<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 编写函数rev(char) 实现将字符串char倒置，比如rev("spring") 返回"gnirp
        function rev(char) {
            // 拆分数组 反转 再拼接起来 split reverse join
           return char.split("").reverse().join("");
        //    没有return  就是undefined
        }
     

          function myRev(char) {
              let str = ""
              for (let i = char.length - 1 ; i >= 0 ; i--) {

                // 中括号
                  str += char[i]
              }
              return str
          }
          console.log(rev("团子是只猫"));
          console.log(myRev("123456789"));
    </script>
</head>
<body>
    
</body>
</html>